﻿using DevExpress.Data.Filtering.Helpers;
using DevExpress.XtraEditors.Filtering;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace 机器组和机器编辑.modify
{
    internal class Machine
    {
        public bool Display { get; set; }  //显示
        public int ID { get; set; } //ID
        public string Name { get; set; } //机器名称
        public string Numbr { get; set; } //机器编号
        public string ModelNumder { get; set; } //机器型号_编号
        public bool Online { get; set; } //在线
        public string Group { get; set; } //机器组名称
        public bool Configuration { get; set; }  //配置项

        public Machine() { }
        public Machine(bool display, int Id, string name, string numbr, string modelNumder, bool online, string group, bool configuration)
        {
            Display = display;
            ID = Id;
            Name = name;
            Numbr = numbr;
            ModelNumder = modelNumder;
            Online = online;
            Group = group;
            Configuration = configuration;
        }
        //历史xml文件数据加载
        public static Machine FromXElement(XElement xe)
        {
            return new Machine
            {

                Display = (bool)xe.Attribute("display"),
                ID = (int)xe.Attribute("id"),
                Name = (string)xe.Attribute("name"),
                Numbr = (string)xe.Attribute("numbr"),
                ModelNumder = (string)xe.Attribute("modelNumder"),
                Online = (bool)xe.Attribute("online"),
                Group = (string)xe.Attribute("group"),
                Configuration = (bool)xe.Attribute("configuration")
            };
        }

        public XElement ToElement()  //映射为xml元素
        {
            return new XElement("Machine",
                new XAttribute("display", Display),
                new XAttribute("id", ID),
                new XAttribute("name", Name),
                new XAttribute("numbr", Numbr),
                new XAttribute("modelNumder", ModelNumder),
                new XAttribute("online", Online),
                new XAttribute("group", Group),
                new XAttribute("configuration", Configuration)
                );
        }
    }
}
